package com.jackiechancinema.ssm.controller;

import com.jackiechancinema.ssm.bo.MoviceBo;
import com.jackiechancinema.ssm.entity.Movices;
import com.jackiechancinema.ssm.service.Inte.MoviceService;
import com.jackiechancinema.ssm.vo.PageVo;
import com.jackiechancinema.ssm.vo.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
public class MoviceController {

    @Autowired
    private MoviceService moviceService;

//    //查询所有
//    @RequestMapping("/find")
//    public PageVo<Movices> find(int page,int limit){
//        PageInfo<Movices> all = moviceService.findAll(page,limit);
//        PageVo<Movices> pageVo = new PageVo<Movices>(SystemContant.PAGE_R,"OK",all.getTotal(),all.getList());
//        return pageVo;
//    }

    //查询所有
    @RequestMapping("/find")
    public PageVo<Movices> find(MoviceBo bo){
//        System.out.println(bo);
//        PageInfo<Movices> all = moviceService.findAll(page,limit);
//        PageVo<Movices> pageVo = new PageVo<Movices>(SystemContant.PAGE_R,"OK",all.getTotal(),all.getList());
//        return pageVo;
        return moviceService.findAllV2(bo);
    }

    //添加
    @RequestMapping("/moviceadd")
    public R MoviceAdd(Movices movices){
        return moviceService.MoviceAdd(movices);
    }

    //修改
    @RequestMapping("/moviceupdate")
    public R MoviceUpdate(Movices movices1){
//        Movices movices1 = new Movices(1,"123","123","123");
        return moviceService.MoviceUpdate(movices1);
    }

    //根据ID删除
    @RequestMapping("/movicedel")
    public R MoviceDel(int id){
        return moviceService.MoviceDel(id);
    }

    //文件上传
    @PostMapping("/batchadd1")
    public R batch(MultipartFile file){
        System.out.println("aaaa");
        return moviceService.insertAddS(file);
    }



}
